package ch.sv7.tool.dbmanager.db.fix;

import ch.sv7.tool.dbmanager.db.ConstraintSchema;
import ch.sv7.tool.dbmanager.db.SchemaElement;
import ch.sv7.tool.dbmanager.db.dialect.DialectException;

/**
 * TODO: Document me!
 *
 * @author svt
 *
 */
public class CreateConstraintFix extends AbstractSchemaFix implements SchemaFix {

	private ConstraintSchema constraint;

	/**
	 * @param constraint
	 */
	public CreateConstraintFix(ConstraintSchema constraint) {
		super();
		this.constraint = constraint;
	}

	public SchemaElement getActionTarget() {
		return constraint;
	}
	

	public String getSQLFix() throws DialectException {
		String ddl = "\n-- Create Constraint Fix \n";
		ddl += getDialect().getAddConstraintDDL(constraint);
		return ddl;
	}

	public int getPriority() {
		return SchemaFix.PRIORITY_CONSTRAINT_CREATION;
	}

	public String getDescription() {
		return "Create constraint " + constraint.getTableSchema().getName() +"."+constraint.getName();
	}

	public int getAction() {
		return ACTION_CREATE;
	}



}
